home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 4 / Mac Giga-ROM 4.0 - 1993.toast / FILES / BBS / MUBBS / E-Mail 1.5 source.cpt / E-mail / DeleteEmail.c < prev    next >
Text File  |  1992-01-03  |  3KB  |  106 lines

  1. /* *********************************************************************************
  2.      
  3.       MODULE:        DeleteEmail Module
  4.       
  5.      DESCRIPTION:    This DeleteEmail Module is a simple module for MUBBS, the
  6.                      Multi-User Bulliten Board System Software.
  7.                      
  8.      AUTHOR:        Noam Freedman
  9.      
  10.      Copyright © 1990 by Noam Freedman. Portions are also Copyright Symantec Corp.
  11.  
  12.      This program source code and it's compiled version IS NOT IN THE
  13.      PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NMF" file for details
  14.      regarding use of this program source code and it's compiled version.
  15.      
  16.      Revision History:
  17.      ============================================================
  18.      10/19/91 - Started programming
  19.      11/ 4/91 - Edited for release
  20.      ============================================================
  21.      
  22.  
  23.     ******************************************************************************** */
  24.  
  25. #define        INMAIN
  26.  
  27.  
  28. #include    "MUBBS Module.h"
  29. #include    <SetUpA4.h>
  30. #include    "Email.h"
  31.  
  32. pascal void main (mode1,G1,P1)
  33.        int mode1;
  34.        struct GS *G1;
  35.        Ptr P1;  
  36. {
  37. Handle temph;
  38. float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
  39. RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
  40. asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
  41.  
  42. G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
  43. mode[u]=mode1; /* set up our mode so that you can read it anywhere */
  44.  
  45. switch (mode[u]) { /* any un-handled modes return error from this module */
  46.     case 3:
  47.         deleteemail(P1); /* mode 3 because we are getting a user struct */
  48.         G->moduleresult=0;
  49.         break;
  50.     case 98:
  51.         versionck(version); /* just return after this call, don't modify anything */
  52.         break;        
  53.     case 0:
  54.         strcpy (G->programmer,"Noam Freedman"); /* show the programmer's name up to 20 chars*/
  55.         G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
  56.         break;
  57.     default:
  58.         G->moduleresult=1; /* return bad code */
  59.     };
  60.  
  61. HUnlock(temph); /* unlocks this module, do this ! */
  62. RestoreA4(); /* call this when you are all done */
  63. }
  64.  
  65.  
  66. deleteemail(S)
  67. struct LoadStruct *S;
  68. {
  69. struct MsgStruct MsgInfo;
  70. int num;
  71. FILE *fp_headers;
  72.  
  73. if (!G->online[u]) { num = 2;goto byebye; } /* do this check so we can log out if hang up */
  74.  
  75.  
  76. strcpy( MsgInfo.FromUser, S->FromUser[S->choice]);
  77. strcpy( MsgInfo.ToUser, G->username[u]);
  78. strcpy( MsgInfo.title, S->title[S->choice]);
  79. MsgInfo.status = DELETED;
  80. strcpy( MsgInfo.NetAddress, S->NetAddress[S->choice]);
  81. MsgInfo.offset = S->offset[S->choice];
  82. MsgInfo.length = S->length[S->choice];
  83. strcpy( MsgInfo.DateSent, S->DateSent[S->choice]);
  84. strcpy( MsgInfo.temp, "NOAM");
  85.  
  86. MsgInfo.status = DELETED;
  87.  
  88.  
  89. if ( (fp_headers = fopen(":msgs:email.headers","r+")) == NULL)
  90.     {
  91.     send("]]Can't open the file: %s]",":msgs:email.headers");
  92.     num = 3;
  93.     }
  94. else
  95.     {
  96.     fseek( fp_headers , S->i_headers[S->choice], SEEK_SET );
  97.     fwrite( MsgInfo.FromUser, sizeof(MsgInfo),1,fp_headers);                    
  98.     fclose(fp_headers);
  99.     send("]Msg \"%s\" was deleted.]",MsgInfo.title);
  100.     num = 0;
  101.     }
  102.     
  103. byebye:
  104. S->result = num;
  105. }
  106.